<html>
<head>
    @include('v1.common.meta')
    <link rel="stylesheet" href="{{elixir('css/basicdata.css')}}">
</head>
<body>
<div class="yjs-grid">
    <div class="yjs-grid-box">
        <div class="layui-tab">
            @if(Auth::check())
                <div class="layui-container">
                    @if($view==='addData')
                        {{--查看视图--}}
                        <div class="layui-row">
                            <div class="layui-col-md12">
                                <fieldset class="layui-elem-field">
                                    <legend>新增角色信息</legend>
                                    <div class="layui-field-box">
                                        <div class="layui-row hidden-tips">
                                            <div class="layui-col-md12">
                                                <blockquote class="layui-elem-quote">
                                                    温馨提示：查看数据时，所有表单项均不可修改。
                                                </blockquote>
                                            </div>
                                        </div>
                                        <div class="layui-form layui-form-pane" name="roleForm"
                                             action="javascript:;" method="POST">

                                            <input type="hidden" name="viewType" value="{{$view}}">

                                            {{--基本信息--}}
                                            {{--<hr class="layui-bg-green">--}}
                                            <div class="layui-row">
                                                <div class="layui-col-md6">
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">角色名称</label>
                                                        <div class="layui-input-inline">
                                                            <input name="display_name" type="text"
                                                                   lay-verify="required"
                                                                   class="layui-input">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-row">
                                                <div class="layui-col-md12">
                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">描述</label>
                                                        <div class="layui-input-block">
                                                            <textarea  name="description" class="layui-textarea"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            权限
                                            <hr class="layui-bg-green">
                                            <div class="layui-row">
                                                <div class="layui-form-item" pane="">
                                                    @foreach($all_permissions as $permission)
                                                        <input type="checkbox" name={{$permission}} lay-skin="primary" title={{\App\Models\V1\Permission::where('name',$permission)->first()['display_name']}}>
                                                    @endforeach
                                                </div>
                                            </div>
                                            <div class="layui-col-md3">
                                                {{--隐藏提交--}}
                                                <button id="toolbarSubmit" type="submit" class="layui-btn"
                                                        lay-filter="toolbarEvent" lay-submit style="display: none;">
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                            </div>
                            </fieldset>
                        </div>
                </div>
            @elseif($view==='editData')
                {{--查看视图--}}
                <div class="layui-row">
                    <div class="layui-col-md12">
                        <fieldset class="layui-elem-field">
                            <legend>编辑【{{$itemData['display_name']}}】角色信息</legend>
                            <div class="layui-field-box">
                                <div class="layui-row hidden-tips">
                                    <div class="layui-col-md12">
                                        <blockquote class="layui-elem-quote">
                                            温馨提示：查看数据时，所有表单项均不可修改。
                                        </blockquote>
                                    </div>
                                </div>
                                <div class="layui-form layui-form-pane" name="roleForm"
                                     action="javascript:;" method="POST">

                                    <input type="hidden" name="viewType" value="{{$view}}">

                                    基本信息
                                    <hr class="layui-bg-green">
                                    <div class="layui-row">
                                        <div class="layui-col-md6">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">角色代码</label>
                                                <div class="layui-input-inline">
                                                    <input name="name" type="text" value="{{$itemData['name']}}" disabled
                                                           class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">角色名称</label>
                                                <div class="layui-input-inline">
                                                    <input name="display_name" type="text" value="{{$itemData['display_name']}}"
                                                           class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">描述</label>
                                                <div class="layui-input-block">
                                                    <textarea  name="description" class="layui-textarea">{{$itemData['description']}}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-row">
                                        <div class="layui-col-md6">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">创建时间</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" value="{{$itemData['created_at']}}"
                                                           disabled class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">更新时间</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" value="{{$itemData['updated_at']}}"
                                                           disabled class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    菜单权限
                                    <hr class="layui-bg-green">
                                    <div class="layui-row">
                                        <div class="layui-form-item" pane="">
                                            @foreach($all_permissions as $permission)
                                                @if(in_array($permission,$role_permissions))
                                                    <input type="checkbox"  name={{$permission}} lay-skin="primary" title={{\App\Models\V1\Permission::where('name',$permission)->first()['display_name']}} checked >
                                                @else
                                                    <input type="checkbox"  name={{$permission}} lay-skin="primary" title={{\App\Models\V1\Permission::where('name',$permission)->first()['display_name']}} >
                                                @endif
                                            @endforeach
                                        </div>


                                        {{--功能权限--}}
                                        {{--<hr class="layui-bg-green">--}}
                                        {{--<div class="layui-row">--}}
                                        {{--<div class="layui-form-item" pane="">--}}
                                        {{--@foreach($all_permissions as $item)--}}
                                        {{--@if(strpos($item['name'],'menu_') === 0)--}}
                                        {{--@elseif(in_array($item,$user_permissions))--}}
                                        {{--用户拥有的权限--}}
                                        {{--<input type="checkbox"  name={{$item['name']}} lay-skin="primary" title={{$item['display_name']}} checked>--}}
                                        {{--@else--}}
                                        {{--<input type="checkbox"  name={{$item['name']}} lay-skin="primary" title={{$item['display_name']}}>--}}
                                        {{--@endif--}}
                                        {{--@endforeach--}}
                                        {{--</div>--}}
                                        {{--</div>--}}

                                        <div class="layui-col-md3">
                                            {{--隐藏提交--}}
                                            <button id="toolbarSubmit" type="submit" class="layui-btn"
                                                    lay-filter="toolbarEvent" lay-submit style="display: none;">
                                            </button>
                                        </div>

                                    </div>
                                </div>
                        </fieldset>
                    </div>
                </div>
            @else
                {{--视图类型不正确--}}
                <div class="layui-row">
                    <div class="layui-col-md12">
                        <blockquote class="layui-elem-quote-error">
                            友情提示：视图类型不正确，无法支持后续操作。
                        </blockquote>
                    </div>
                </div>
            @endif
        </div>
        @else
            <div class="layui-container">
                <div class="layui-row">
                    <div class="layui-col-md12">
                        <blockquote class="layui-elem-quote-error">
                            友情提示：该功能只面向已成功登录系统，并具有相应权限的用户可用。
                        </blockquote>
                    </div>
                </div>
            </div>
        @endif
    </div>
</div>
</div>

@include('v1.common.js')
<script src="{{elixir('js/role_item.js')}}"></script>
</body>
<script type="text/html">
    <input type="hidden" id="rspStatus" value="">
    <input type="hidden" id="rspMsg" value="">
</script>
<script>

</script>

<style>
    .layui-form-checkbox span{padding:0 10px;height:5%;font-size:14px;background-color:#d2d2d2;color:#fff;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
</style>
</html>